﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loyalty.Core.Entities
{
    public class City
    {
        public virtual int Id { get; set; }

        public virtual string Title { get; set; }

        public virtual Province Province { get; set; }

        public virtual int? LinkProvinceId { get; set; }

        public ICollection<Profile> Profiles { get; set; }
    }
}


namespace Loyalty.Core.Entities.Mapping
{
    public class CityMap : EntityTypeConfiguration<City>
    {
        public CityMap()
        {
            this.ToTable("City");
            this.HasKey(x => x.Id);

            this.Property(x => x.Title).HasMaxLength(50).HasColumnName("Title");


            this.HasOptional(x => x.Province).WithMany(x => x.Cities).HasForeignKey(x => x.LinkProvinceId).WillCascadeOnDelete(true);
        }
    }
}